using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using Microsoft.Win32.SafeHandles;

namespace Gko.Utils
{
	/// <summary>
	/// See http://msdn.microsoft.com/msdnmag/issues/05/10/Reliability/ for more about safe handles.
	/// </summary>
	[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
	internal sealed class SafeLibraryHandle : SafeHandleZeroOrMinusOneIsInvalid
	{
		private SafeLibraryHandle()
			: base(true)
		{
		}

		protected override bool ReleaseHandle()
		{
			return NativeMethods.FreeLibrary(this.handle);
		}
	}
}